<?php

class Empeval_Methods_Data_BonusGoalsForm extends Empeval_Methods_Data_BaseBonusGoalsForm {
	
	/**
	 * 
	 * @var Empeval_Methods_Data_BaseUser
	 */
	public $user;
	/**
	 *
	 * @var Empeval_Methods_Data_BaseUser
	 */
	public $superior = null;
	/**
	 * 
	 * @var Empeval_Methods_Data_Reject
	 */
	public $reject = null;
	/**
	 * 
	 * @var Empeval_Methods_Data_Summary
	 */
	public $summary = null;
	/**
	 * 
	 * @var Empeval_Methods_Data_EmployeeEvaluation
	 */
	public $evaluation = null;
	/**
	 * 
	 * @var Empeval_Methods_Data_MboGoals[]
	 */
	public $functionMboGoals = array();
	/**
	 * 
	 * @var Empeval_Methods_Data_MboGoals[]
	 */
	public $personalMboGoals = array();
	/**
	 * 
	 * @var Empeval_Methods_Data_TaskGoals[]
	 */
	public $taskGoals = array();
	/**
	 * 
	 * @var Empeval_Methods_Data_Kpi[]
	 */
	public $kpi = array();
	
	public function __construct(EmpevalViewBgfWithSuperiorPositionId $bgf) {
		$this->user = new Empeval_Methods_Data_BaseUser($bgf->getUserPositionsRelatedByUserPositionId()->getUsers(), false, true, $bgf->getUserPositionsRelatedByUserPositionId()->getPositions());
		parent::__construct($bgf);
		if ($bgf->getUserPositionsRelatedBySuperiorUserPositionId() instanceof EmpevalUserPositions)
			$this->superior = new Empeval_Methods_Data_BaseUser($bgf->getUserPositionsRelatedBySuperiorUserPositionId()->getUsers(), true, false);
		if ($bgf->getRejections() instanceof EmpevalRejections)
			$this->reject = new Empeval_Methods_Data_Reject($bgf->getRejections());
		if ($bgf->getSummarys()->getFirst() instanceof EmpevalSummary)
			$this->summary = new Empeval_Methods_Data_Summary($bgf->getSummarys()->getFirst());
		if ($bgf->getEmployeeEvaluations() instanceof EmpevalEmployeeEvaluations)
			$this->evaluation = new Empeval_Methods_Data_EmployeeEvaluation($bgf->getEmployeeEvaluations());
		if ($bgf->getType() == EmpevalBonusGoalsForms::LOW_GRADE_FORM) {
			foreach ($bgf->getTaskGoalss() as $taskGoals) {
				$this->taskGoals[] = new Empeval_Methods_Data_TaskGoals($taskGoals);
			}
			foreach ($bgf->getKpis() as $kpi) {
				$this->kpi[] = new Empeval_Methods_Data_Kpi($kpi);
			}
		} else {
			foreach ($bgf->getMboGoalss() as $mboGoals) {
				if ($mboGoals->getType() == EmpevalMboGoals::TYPE_FUNCTION)
					$this->functionMboGoals[] = new Empeval_Methods_Data_MboGoals($mboGoals);
				else
					$this->personalMboGoals[] = new Empeval_Methods_Data_MboGoals($mboGoals);
			}
		}
	}
	
}